#include <bits/stdc++.h>
using namespace std;

#define int long long
int n;
unordered_map<string, int> mp;
string a[6];

signed main()
{
    int ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= 5; j++)
            cin >> a[j];
        sort(a + 1, a + 6);
        for (int j = 1; j < 32; j++) {
            int cnt = 0;
            string s;
            for (int k = 1; k <= 5; k++) {
                if (j & (1 << k - 1))
                    cnt++, s += a[k] + " ";
            }
            if (cnt & 1)
                ans += mp[s];
            else
                ans -= mp[s];
            mp[s]++;
        }
    }
    cout << n * (n - 1) / 2 - ans;
    return 0;
}